<extend name="Public/base" />

<block name="body">
     
    <div class="main-title">
        <h2>帖子列表 [ {$circle.name} ] <button class="btn btn-default btn-return" onclick="javascript:window.location.reload();return false;"><i class="glyphicon glyphicon glyphicon-refresh"></i> 刷新</button>
        <a href="{:U('circle/index')}" class="btn btn-default btn-return"><i class="glyphicon glyphicon-arrow-left"></i>返回</a>

        </h2>

    </div>
    
    <notempty name="top_list">
    <div>置顶帖 (请先取消, 后删除)</div>
        <div class="data-table table-striped">
            <table class="table table-bordered">
            <thead>
                <tr>
                <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                <!-- <th class="">ID</th> -->
                <th width="10%" class="">标题</th>
                <th class="">类型</th>
                <th class="">用户</th>
                <th class="">状态</th>
                <th class="">创建于</th>
                <th class="">更新于</th>
                <th class="">楼层</th>
                <th width="300" class="">操作</th>
                </tr>
            </thead>
            <tbody>
                
                <volist name="top_list" id="vo">
                <tr>
                    <td width="1%"><input class="ids" type="checkbox" name="id[]" value="{$key}" /></td>
                    <!--<td>
                        {$key}
                    </td> -->
                    <td>
                        {$vo.title}
                    </td>
                    <td>
                        {$vo.attachment_type_text|default=文字}
                        <eq name="vo.attachment_type" value="2">
                        | <a href="{:U('video/edit?id='.$vo['video']['id'])}" target="_blank">{$vo.video.id}</a>
                        </eq>
                    </td>
                    <td><a href="{:U('FrontUsers/profile?id='.$vo['uid'])}" target="_blank">{$vo.uid} | {$vo.uid|get_nickname}</a></td>
                    <td>
                        <eq name="vo.status" value="1">
                            <span class="label label-success">显示</span>
                            <else />
                            <span class="label label-danger">关闭</span>
                            </eq>
                    </td>
                    <td>{$vo.created_at|time_format}</td>
                    <td>{$vo.updated_at|time_format}</td>
                    <td> <a href="{:U('posts/index?threads_id='.$key)}">{$vo.floor} <i class="glyphicon glyphicon-comment"></i></a>
                    </td>

                    <td>
                        <a class="btn btn-default btn-xs" title="编辑" href="{:U('edit?id='.$key)}"><i class="glyphicon glyphicon-pencil"></i></a>
                        <a title="取消置顶" href="{:U('top?type=down&id='.$key)}" class="ajax-get btn btn-default btn-xs"><i class="glyphicon glyphicon glyphicon-hand-down
"></i></a>
                    </td>
                </tr>
                </volist>
            </tbody>
            </table>
            </div>
        </notempty>

    <br/>
    <div class="cf">
        <div class="fl">
            <a title="新增" class="btn btn-primary" href="{:U('add?circle_id='.$circle_id)}"><i class="glyphicon glyphicon-plus"></i></a>  
            <a href="{:U('index?circle_id='.$circle_id)}" class="btn btn-default btn-return"><i class="glyphicon glyphicon-share-alt"></i>所有</a>
            <div class="btn-group">
              <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                {$attachment_type_text|default=所有类型} <span class="caret"></span>
              </button>
              <ul class="dropdown-menu" role="menu">
                <li><a href="{:U('index?'.$args.'&attachment_type=null')}">文字</a></li>
                <li><a href="{:U('index?'.$args.'&attachment_type=1')}">图片</a></li>
                <li><a href="{:U('index?'.$args.'&attachment_type=2')}">视频</a></li>
              </ul>
            </div>

            <div class="btn-group">
              <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                {$status_text|default=所有状态} <span class="caret"></span>
              </button>
              <ul class="dropdown-menu" role="menu">
                <li><a href="{:U('index?'.$args.'&status=1')}">显示</a></li>
                <li><a href="{:U('index?'.$args.'&status=0')}">关闭</a></li>
              </ul>
            </div>

        </div>

        <!-- 高级搜索 -->
        <div class="search-form fr cf">
        <div class="sleft">
             <input type="text" name="title" class="search-input form-control" value="{:I('title')}" placeholder="请输入标题">
                <a class="sch-btn" href="javascript:;" id="search" url="{:U('index?'.$args)}"><i class="btn-search"></i></a>
        </div>        
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
    <table class="table table-bordered">
    <thead>
        <tr>
        <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
        <!-- <th class="">ID</th> -->
        <th width="10%" class="">标题</th>
        <th class="">类型</th>
        <th class="">用户</th>
        <th class="">状态</th>
        <th class="">创建于</th>
        <th class="">更新于</th>
        <th class="">楼层</th>
        <th width="300" class="">操作</th>
        </tr>
    </thead>
    <tbody>
        <notempty name="_list">
        <volist name="_list" id="vo">
        <tr>
            <td width="1%"><input class="ids" type="checkbox" name="id[]" value="{$key}" /></td>
            <!--<td>
                {$key}
            </td> -->
            <td>
                {$vo.title}
            </td>
            <td>
                {$vo.attachment_type_text|default=文字}
                <eq name="vo.attachment_type" value="2">
                | <a href="{:U('video/edit?id='.$vo['video']['id'])}" target="_blank">{$vo.video.id}</a>
                </eq>
            </td>
            <td><a href="{:U('FrontUsers/profile?id='.$vo['uid'])}" target="_blank">{$vo.uid} | {$vo.uid|get_nickname}</a>   <a href="{:U('index?'.$args.'&uid='.$vo['uid'])}" class="btn btn-default btn-xs"><i class="glyphicon glyphicon-file">查看他的</i></a></td>
            <td>
            <eq name="vo.status" value="1">
            <span class="label label-success">显示</span>
            <else />
            <span class="label label-danger">关闭</span>
            </eq>
            </td>
            <td>{$vo.created_at|time_format}</td>
            <td>{$vo.updated_at|time_format}</td>
            <td><a href="{:U('posts/index?threads_id='.$key)}">{$vo.floor} <i class="glyphicon glyphicon-comment"></i></a></td>
            <td>
                <a class="btn btn-default btn-xs" title="编辑" href="{:U('edit?id='.$key)}"><i class="glyphicon glyphicon-pencil"></i></a>
                <a title="置顶" href="{:U('top?type=up&id='.$key)}" class="ajax-get btn btn-default btn-xs"><i class="glyphicon glyphicon glyphicon-hand-up"></i></a>
                <a href="{:U('trash?id='.$key)}" class="confirm ajax-get btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a>
            </td>
        </tr>
        </volist>
        <else/>
        <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
        </notempty>
    </tbody>
    </table>
    </div>
    <div class="page">
        {$_page}
    </div>
    <div id="video-pre">
        <video controls="controls" autoplay="autoplay"></video>
    </div>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

    <script type="text/javascript">
    //搜索功能
    $("#search").click(function(){
        var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');

        var game  = $('.search-form').find('select').serialize();
        game = game.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        game = game.replace(/^&/g,'');

        if( url.indexOf('?')>0 ){
            url += '&' + query + '&' + game;
        }else{
            url += '?' + query + '&' + game;
        }
        window.location.href = url;
    });
    //回车搜索
    $(".search-input").keyup(function(e){
        if(e.keyCode === 13){
            $("#search").click();
            return false;
        }
    });
    //导航高亮
    highlight_subnav('{:U('index')}');
     
    </script>
</block>
